<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<?php
session_start();
include_once '../Model/usuarioDao.php';
if(isset($_POST['User'])){
    $usuario = $_POST['User'];
    $contra = $_POST['password'];

    $result = usuario($usuario);
    if(sizeof($result)==1){
        $passWord = $result[0]['passWord'];
        if(strcmp($passWord,$contra)==0) {
            $_SESSION['usuario'] = $usuario;
            $_SESSION['rol'] = $result[0]['roleCode'];
            header('Location: '.'../Menu/menuPrincipal.php');
        } else {
            $_SESSION['message'] = 'Password not match.';
            echo 'Password not match.';
            header('Location: ../');

        }
    } else {
        $_SESSION['message'] = 'User not found.';
        echo 'User not found.';
        header('Location: ../');
    }
} else {
    $_SESSION['message'] = 'User field empty.';
    echo 'User field empty.';
    header('Location: ../');
}
?>
    </body>
</html>
